package com.developtools.utils;

import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.NotNullComputable;
import org.jetbrains.annotations.NotNull;

import java.util.function.Supplier;

/**
 * @author liujun
 */
public class GetUtils {

    public static <T> T get(Supplier<T> supplier){
        Application application = ApplicationManager.getApplication();
        return application.runReadAction(new NotNullComputable<T>() {
            @Override
            public @NotNull T compute() {
                return supplier.get();
            }
        });
    }
}
